/*
 *	entrypoint.c 
 *	© 2009 Tom Booth
 *
 *	Entry point into the threading test harness
 *
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>


#include "dfdiscover.h"

static void handle_servers(df_server *servers);

int done = 0;

int main(int argc, char *argv[]) {
	
	printf("Searching for servers ");
	
	dfdiscover_go(10, handle_servers);
	
	while (done==0) {sleep(1);}

}



static void handle_servers(df_server *servers) {
	df_server *current;
	
	printf(" Done.\n");
	
	if (servers!=NULL) {
		printf("Avaliable Servers\n-------------------------\n");
		current = servers;
		while (current!=NULL) {
			printf("%s\t%s\t%s\n", current->name, current->version, current->address);
			
			current = current->next;
		}
	}
	else {
		printf("got no servers :(\n");
	}
	
	done =1 ;
}



